<template>
<view class="coupon" :style="'opacity:' + (coupon.totalAvailable===0 ? '0.5' : '') + ';background-image: linear-gradient(to bottom right, ' + couColorStar[coupon.couponType] + ', ' + couColorEnd[coupon.couponType] + ')'">
  <view class="coupon__top">
    <view class="coupon__top--price">
      <view class="coupon__top--price--discount">
        <span v-if="coupon.couponType===0 || coupon.couponType===2">{{coupon.discount}}</span>
        <span v-else>{{coupon.discountAmount}}</span>
      </view>
      <view class="coupon__top--price--type">
        {{coupon.couponType===0 || coupon.couponType===2?'折':'元'}}
      </view>
    </view>
    <view class="coupon__top--sign">
      {{coupon.couponType===0 || coupon.couponType===2?'折扣券':'现金券'}}
    </view>
    <view class="couponText">{{coupon.productType===0?'全店商品':'指定商品'}}</view>
  </view>
  <view class="coupon__item">
    <view v-if="coupon.couponType===0 || coupon.couponType===1" :style="'color:' + couColor[coupon.couponType]">
      无门槛使用
    </view>
    <view v-if="coupon.couponType===2 || coupon.couponType===3" :style="'color:' + couColor[coupon.couponType]">
      满{{coupon.conditionAmount}}可使用
    </view>
  </view>
  <view class="line"></view>
  <view class="circle" v-if="coupon.totalAvailable===0">
    <view class="circle__inside">
      <view class="circle__inside--title">已兑完</view>
    </view>
  </view>
</view>
</template>
<script lang='ts'>
import { Component, Vue,Prop } from 'vue-property-decorator'

@Component
export default class Coupon extends Vue {
    @Prop()
    coupon:any
    couColorStar= ["#ffbf00", "#ED6C70", "#4bc8ff", "#5B9EE6"]
    couColorEnd= ["#ff9600", "#FD9A80", "#E5FCFF", "#5CD4E2"]
}
</script>
<style lang="scss" scoped>
@include b(coupon) {
    width: 146px;
    height: 80px;
    // background-color: greenyellow;
    // background-image: linear-gradient(to bottom right, red, yellow);
    border-radius: 10px;
    padding: 10px;
    position: relative;

    @include e(top) {
        display: flex;

        @include m(price) {
            width: 45px;
            height: 45px;
            display: flex;
            align-items: flex-end;

            @include m(discount) {
                font-size: 28px;
                display: flex;
                align-items: center;
                font-weight: bold;
                height: 47px;
                justify-content: center;
                color: #fff;
            }

            @include m(type) {
                margin-left: 2px;
                height: 40px;
                display: flex;
                justify-content: center;
                align-items: center;
                color: #fff;
                font-size: 15px;
            }
        }

        @include m(sign) {
            width: 50px;
            height: 20px;
            margin-left: 15px;
            border-radius: 50px;
            color: white;
            @include flex(center, center);
            border: 1px solid white;
            font-size: 11px;

            @include m(line) {
                width: 1px;
                border: 1px dotted white;
            }
        }
    }

    @include e(item) {
        color: white;
        font-size: 14px;
    }
}

.couponText {
    width: 30rpx;
    margin: 0 auto;
    line-height: 30rpx;
    padding-left: 10rpx;
    margin-top: 2rpx;
    position: absolute;
    right: 14rpx;
    top: 26rpx;
    font-size: 11px;
    color: white;
}

.line {
    width: 2px;
    border: 1px dotted white;
    position: absolute;
    top: 0px;
    right: 22px;
    height: 85px;
}

.line::before {
    content: '';
    position: absolute;
    top: -5px;
    bottom: 0px;
    left: -4.5px;
    width: 10px;
    height: 10px;
    background-color: white;
    border-radius: 50px;
}

.line::after {
    content: '';
    position: absolute;
    top: 75px;
    bottom: 0px;
    left: -4.5px;
    width: 10px;
    height: 10px;
    background-color: white;
    border-radius: 50px;
}

.circle{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 100%;
    border: 3px solid #999999;
    position: absolute;
    top: 0px;
    left: 35px;
} 

.circle__inside {
    width: 56px;
    height: 56px;
    border-radius: 100%;
    border: 1px solid #999999;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle__inside--title{
    position: relative;
    top: 0px;
    left: 0px;
    font-size: 14px;
    transform: rotate(-15deg);
    color: #999999;
}
</style>